
using System;
using System.Collections;
using System.Web.UI.WebControls;

using Awaken.Framework;
using Nullables;

namespace Northwind.Domain.Entities
{
    public partial class Customer : IEntity
    {
        protected static CustomerBroker broker;
        public static CustomerBroker Broker
        {
            get
            {
                if (broker == null)
                {
                    broker = new CustomerBroker();
                }
                return broker;
            }
        }

        #region IEntity Members

        public string EntityID
        {
            get { return string.Empty; }
        }
        
        public string EntityName
        {
            get { return string.Empty; }
        }

        public void Save()
        {
            Broker.Save(this);
        }
        
        public void Delete()
        {
            Broker.Delete(this);
        }
        
        #endregion
    
        #region Constructor
        
        public Customer()
        {
            // Default, no arg constructor.
        }
        
        #endregion
            
        #region Public Properties / Protected Fields
                        
        
        protected string _CustomerID;
        public string CustomerID
        {
            get{ return _CustomerID; }
            set{ _CustomerID=value; }
        }
        
        protected string _CompanyName;
        public string CompanyName
        {
            get{ return _CompanyName; }
            set{ _CompanyName=value; }
        }
        
        protected string _ContactName;
        public string ContactName
        {
            get{ return _ContactName; }
            set{ _ContactName=value; }
        }
        
        protected string _ContactTitle;
        public string ContactTitle
        {
            get{ return _ContactTitle; }
            set{ _ContactTitle=value; }
        }
        
        protected string _Address;
        public string Address
        {
            get{ return _Address; }
            set{ _Address=value; }
        }
        
        protected string _City;
        public string City
        {
            get{ return _City; }
            set{ _City=value; }
        }
        
        protected string _Region;
        public string Region
        {
            get{ return _Region; }
            set{ _Region=value; }
        }
        
        protected string _PostalCode;
        public string PostalCode
        {
            get{ return _PostalCode; }
            set{ _PostalCode=value; }
        }
        
        protected string _Country;
        public string Country
        {
            get{ return _Country; }
            set{ _Country=value; }
        }
        
        protected string _Phone;
        public string Phone
        {
            get{ return _Phone; }
            set{ _Phone=value; }
        }
        
        protected string _Fax;
        public string Fax
        {
            get{ return _Fax; }
            set{ _Fax=value; }
        }
        
        
        
        // One-To-Many: Orders.CustomerID  
        protected IList _OrderList;
        public IList OrderList
        {
            get{ return _OrderList; }
            set{ _OrderList=value; }
        }
        
        
                
        
        
        // Many-To-Many: CustomerCustomerDemo
        protected IList _CustomerDemographicList;
        public IList CustomerDemographicList
        {
            get{ return _CustomerDemographicList; }
            set{ _CustomerDemographicList=value; }
        }
        
        
        #endregion
    }
    
    #region CustomerBroker

    public partial class CustomerBroker : IBroker
    {
        #region IBroker Members

        public Type EntityType
        {
            get { return typeof(Customer); }
        }
        
        public Customer GetByID(object id)
        {
            return (Customer)Awaken.Framework.Gateway.GetByID(EntityType, id);
        }

        public IList GetAll()
        {
            return Awaken.Framework.Gateway.GetAll(EntityType);
        }

        public void Save(IEntity entity)
        {
            Awaken.Framework.Gateway.Save(entity);
        }
        
        public void Delete(IEntity entity)
        {
            Awaken.Framework.Gateway.Delete(entity);
        }
        
        #endregion
    }
    #endregion
}
